Skip to content

fix: arrays_zip/list_zip allow single array argument #21047

Merged
comphead merged 8 commits intoapache:mainfrom
hsiang-c:single_arg_arrays_zip
Mar 20, 2026
Merged

fix: arrays_zip/list_zip allow single array argument #21047
comphead merged 8 commits intoapache:mainfrom
hsiang-c:single_arg_arrays_zip

Conversation

@hsiang-c
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Align DataFusion's arrays_zip implementation w/ DuckDB and Spark

What changes are included in this PR?

  • Allow single array argument
  • Update user doc and fix a few examples

Are these changes tested?

Yes, by sqllogictest

Are there any user-facing changes?

Yes, I modified user doc.

@github-actions github-actions bot added documentation Improvements or additions to documentation sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Mar 18, 2026
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hsiang-c the PR looks good to me
Please add also tests with some unary edge cases

arrays_zip(null), arrays_zip(array()), arrays_zip(array(null))


# column-level test with single argument
query ?
select arrays_zip(a) from (values ([1, 2], [10, 20]), (null, [30, 40]), ([5, 6], null)) as t(a, b);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test on column a

[{1: 5}, {1: 6}]

query ?
select arrays_zip(b) from (values ([1, 2], [10, 20]), (null, [30, 40]), ([5, 6], null)) as t(a, b);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test on column b

@hsiang-c
Copy link
Contributor Author

@comphead Added, thank you for your review.

hsiang-c and others added 4 commits March 19, 2026 09:48
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
@comphead
Copy link
Contributor

Some tests are failing on arrays_zip

@comphead
Copy link
Contributor

Thanks @hsiang-c and @martin-g for review

@comphead comphead added this pull request to the merge queue Mar 20, 2026
Merged via the queue into apache:main with commit 9885f4b Mar 20, 2026
31 checks passed
@hsiang-c hsiang-c deleted the single_arg_arrays_zip branch March 20, 2026 17:05
haohuaijin pushed a commit to haohuaijin/arrow-datafusion that referenced this pull request Mar 21, 2026
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

- Closes apache#21046

## Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

Align DataFusion's `arrays_zip` implementation w/ DuckDB and Spark

## What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

- Allow single array argument
- Update user doc and fix a few examples

## Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

Yes, by sqllogictest

## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

Yes, I modified user doc.

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

---------

Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arrays_zip/list_zip should allow single array argument

3 participants